import { getTelePhone } from "../../api/shop";

Component({
  mixins: [],
  data: {
    shop_mobile: '',
    platform_mobile: ''
  },
  props: {
    serviceShow: false,
    memberId: ''
  },
  didMount() {
  },
  didUpdate() {
    const { serviceShow, memberId } = this.props;
    
    if (serviceShow) {
      getTelePhone(memberId).then(res => {
        this.setData({
          shop_mobile: res.shop_mobile,
          platform_mobile: res.platform_mobile
        })
      })
    }
  },
  didUnmount() { },
  methods: {
    closeModal() {
      this.props.onCloseService();
    },
    goToService() {
      my.switchTab({
        url: '/pages/service/service'
      })
    },
    callPhone(e) {
      const phone = e.currentTarget.dataset.phone;
      if (phone) {
        my.makePhoneCall({ number: phone })
      }
    }
  },
});
